/**
 * Created by gbolin on 2017/8/19.
 */
/*
window.onload=function () {
    /!*轮播图*!/
    var mySwiper = new Swiper('.swiper-container',{
        pagination: '.pagination',
        paginationClickable: true,
        loop: true,
        observer:true,
        observeParents:true,
        autoplayDisableOnInteraction : false,
        autoplay:2500
    });
    /!*轮播图*!/

    /!*悬浮控制*!/
    var timer;
    $(function () {
        $(window).on("scroll",function (event) {
            var speedNum=10;
            var e=event||window.event;
            var scrollTopNum=$("body").scrollTop()||$(document).scrollTop();
            /!*判断滚动距离 大于500显示悬浮区域 否则 不显示*!/
            if(scrollTopNum>500){
                $("#suspension").css("display","block");
            }else{
                $("#suspension").css("display","none");
            }
            /!*判断滚动距离 大于500显示悬浮区域 否则 不显示*!/

            /!*返回顶部（缓慢）*!/
            $("#backTop").on("click",function () {
                clearInterval(timer);
                timer=setInterval(function () {
                    var oScrollTop=$("body").scrollTop()||$(document).scrollTop();
                    speedNum+=10;
                    $("body").scrollTop(oScrollTop-speedNum);
                    $(document).scrollTop(oScrollTop-speedNum);
                    if(oScrollTop<=0){
                        clearInterval(timer);
                    }
                },30)
            })
            /!*返回顶部（缓慢）*!/
        })
    });
    /!*悬浮控制*!/
    /!*搜索框*!/
    $("#seach").on("input",function () {
         if($(this).val()!=""){
             $("#poor").css("display","block");
         }else{
             $("#poor").css("display","none");
         }
    });
    $("#poor").on("click",function () {
        if($("#seach").val()!=""){
            $("#seach").val("").focus();
            $(this).css("display","none");
        }
    });
    $("#oBtnA").on("click",function () {
         if($("#seach").val()!=""){
             location.href="search.html?SearchContent="+$("#seach").val();
         }
    });
    document.onkeydown=function(event){
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if(e && e.keyCode==13){
            $('#oBtnA').trigger("click");
            return false;
        }
    };
    /!*搜索框*!/
    /!**
     *  小学初中进行切换
     *  @ele:小学初中按钮
     *  @elePar:内容的容器
     * *!/
   function juniorHighSchoolswitching(ele,elePar) {
        $(ele).on("click",function () {
            $(ele).removeClass("selected");
            $(this).addClass("juniorHighSchool selected");
            $(elePar).css("display","none");
            $(elePar).eq($(this).index()-1).css("display","block");

        });
   }
   /!*阳光计划系列*!/
    juniorHighSchoolswitching("#leftSunA .juniorHighSchool","#sunshineProject .sunProjectContent");
    /!*阳光计划系列*!/
    /!*练出好成绩*!/
    juniorHighSchoolswitching("#leftSunB .juniorHighSchool","#getGoodGrades .sunProjectContent");
    /!*练出好成绩*!/

};*/


$(function () {
    /*轮播图*/
    var mySwiper = new Swiper('.swiper-container',{
        pagination: '.pagination',
        paginationClickable: true,
        loop: true,
        observer:true,
        observeParents:true,
        autoplayDisableOnInteraction : false,
        autoplay:2500
    });
    /*轮播图*/
    /*悬浮控制*/
    var timer;
    $(window).on("scroll",function (event) {
        var speedNum=10;
        var e=event||window.event;
        var scrollTopNum=$("body").scrollTop()||$(document).scrollTop();
        /*判断滚动距离 大于500显示悬浮区域 否则 不显示*/
        if(scrollTopNum>500){
            $("#suspension").css("display","block");
        }else{
            $("#suspension").css("display","none");
        }
        /*判断滚动距离 大于500显示悬浮区域 否则 不显示*/

        /*返回顶部（缓慢）*/
        $("#backTop").on("click",function () {
            clearInterval(timer);
            timer=setInterval(function () {
                var oScrollTop=$("body").scrollTop()||$(document).scrollTop();
                speedNum+=10;
                $("body").scrollTop(oScrollTop-speedNum);
                $(document).scrollTop(oScrollTop-speedNum);
                if(oScrollTop<=0){
                    clearInterval(timer);
                }
            },30)
        })
        /*返回顶部（缓慢）*/
    });
    /*悬浮控制*/


    /*搜索框*/
    $("#seach").on("input",function () {
        if($(this).val()!=""){
            $("#poor").css("display","block");
        }else{
            $("#poor").css("display","none");
        }
    });
    $("#poor").on("click",function () {
        if($("#seach").val()!=""){
            $("#seach").val("").focus();
            $(this).css("display","none");
        }
    });
    $("#oBtnA").on("click",function () {
        if($("#seach").val()!=""){
            //location.href="search.html?SearchContent="+$("#seach").val();
            $("#fomA").submit();
        }
    });
    document.onkeydown=function(event){
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if(e && e.keyCode==13){
            $('#oBtnA').trigger("click");
            return false;
        }
    };
    /*搜索框*/

  /*  /!**
     *  小学初中进行切换
     *  @ele:小学初中按钮
     *  @elePar:内容的容器
     * *!/
    function juniorHighSchoolswitching(ele,elePar) {
        $(ele).on("click",function () {
            $(ele).removeClass("selected");
            $(this).addClass("juniorHighSchool selected");
            $(elePar).css("display","none");
            $(elePar).eq($(this).index()-1).css("display","block");
            if(ele=="#leftSunA .juniorHighSchool"){
                //$("#moreA").attr("href","/course/explore?category="+$(this).attr("dataId"));
                if($(this).attr("dataId")=="ygjhxx"){
                    $("#moreA").attr("href",ygjhxxUrl);
                }else{
                    $("#moreA").attr("href",ygjhczUrl);
                }
            }else {
                //$("#moreB").attr("href","/course/explore?category="+$(this).attr("dataId"));
                if($(this).attr("dataId")=="lchcjxx"){
                    $("#moreB").attr("href",lchcjxxUrl);
                }else{
                    $("#moreB").attr("href",lchcjczUrl);
                }
            }


        });
    }
    /!*阳光计划系列*!/
    juniorHighSchoolswitching("#leftSunA .juniorHighSchool","#sunshineProject .sunProjectContent");
    /!*阳光计划系列*!/
    /!*练出好成绩*!/
    juniorHighSchoolswitching("#leftSunB .juniorHighSchool","#getGoodGrades .sunProjectContent");
    /!*练出好成绩*!/*/



    /*分类滑动*/
    var brandMoveSon=$("#brandMove").children().length;//一共多少个分类

    var clicks=brandMoveSon-4;
    var brandMoveA=$("#brandMove .brandMoveContent").outerWidth();//每一个分类的宽度

    $("#brandMove").width(brandMoveSon*brandMoveA);//分类的总宽度
    var currentLeftA=parseInt($("#brandMove").css("left"));//当前的left值
    var num=0;
    if(brandMoveSon>4){
        $("#prev").attr('class','btnFl btnFlShow');
        $("#next").attr('class','btnFl btnFlShow');
    }else{
        $("#prev").attr('class','btnFl');
        $("#next").attr('class','btnFl');
    }
    $("#next").on("click",function () {

        if(num<clicks){
            num++;
        }
        $("#brandMove").animate({
            left:-brandMoveA*num+"px"
        },200);




    });
    $("#prev").on("click",function () {
        num=0;
        var currentLeft=parseInt($("#brandMove").css("left"));//当前的left值
        if(currentLeft<0){
            $("#brandMove").animate({
                left:(currentLeft+=brandMoveA)+"px"
            },200);
        }else{
            $("#brandMove").animate({
                left:0+"px"
            },200);
        }


    });

    /*分类滑动*/
});